package io.summer.basis.http;

import org.springframework.http.HttpStatus;
import org.springframework.http.client.ClientHttpResponse;
import org.springframework.web.client.DefaultResponseErrorHandler;

import java.io.IOException;

/**
 * @author Moonlight
 */
public class CustomResponseHandler extends DefaultResponseErrorHandler {
  @Override
  public boolean hasError(ClientHttpResponse response) throws IOException {
    int rawStatusCode = response.getRawStatusCode();
    HttpStatus statusCode = HttpStatus.resolve(rawStatusCode);
    if(statusCode == HttpStatus.METHOD_NOT_ALLOWED) {
      return false;
    }
    return super.hasError(response);
  }
}
